package org.gongliang.jsmile.common.task;

import java.util.Map;

import org.gongliang.jsmile.authc.task.entity.QrtzTask;
import org.gongliang.jsmile.common.constants.KConstant;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

/**
 * 有状态任务
 * 
 * @description 若一个方法一次执行不完下次轮转时则等待改方法执行完后才执行下一次操作
 * @author 龚亮
 * @date 2015-05-27 14:22:13
 */
@DisallowConcurrentExecution
public class QuartzJobFactoryDisallowConcurrentExecution implements Job {

	@Override
	@SuppressWarnings("unchecked")
	public void execute(JobExecutionContext context) throws JobExecutionException {
		QrtzTask scheduleJob = (QrtzTask) context.getMergedJobDataMap().get(KConstant.TASK.SCHEDULE_JOB);
		Map<String, Object> data = (Map<String, Object>) context.getMergedJobDataMap().get(KConstant.TASK.JOB_DATA_MAP);
		TaskKit.invokMethod(scheduleJob, data);
	}

}